package com.iona.json.builders;

import java.util.List;

import com.iona.domain.Semester;
import com.iona.json.JSONArray;
import com.iona.json.JSONBuilder;
import com.iona.json.JSONException;

public class SemesterBuilder extends JSONBuilder {
	private List<Semester> semesters;

	public SemesterBuilder(List<Semester> semesters) {
		this.semesters = semesters;
	}

	@Override
	public Object build() throws JSONException {
		JSONArray root = new JSONArray();
		for (Semester s : semesters) {
			JSONArray arr = new JSONArray();
			arr.put(s.getId());
			arr.put(s.getNumber());
			root.put(arr);
		}

		return root;
	}

	@Override
	public String name() {
		return SemesterBuilder.class.getSimpleName();
	}

}
